package com.octocat.service.impl;

import com.octocat.dao.UserDao;
import com.octocat.dao.impl.UserDaoImpl;
import com.octocat.pojo.User;
import com.octocat.service.UserService;

/**
 * Author : Octocat
 * Date   : 2021/5/22
 */
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();

    @Override
    public void registerUser(User user) {
        userDao.saveUserInfo(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUserNameAndPassword(user.getUserName(),user.getUserPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if(userDao.queryUserByUserName(username) == null){
            //等于 null 表示没有查到，没有查到表示该用户名可用
            return false;
        }
        return true;
    }
}
